﻿using pingjia.bll;
using PJTY.dal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class views_customer_Change2 : System.Web.UI.Page
{
    ConsumerService customeSrv = new ConsumerService();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"] == null)  //用户未登录
        {
            Response.Redirect("../Login.aspx");
        }
    }

    protected void Unnamed1_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            //调用CustomerService类中的CheckLogin()方法检查Session变量CustomerName关联的用户名和输入的原密码，返回值大于0表示输入的原密码正确
            if (customeSrv.CheckLogin(Session["username"].ToString(), txtOldPwd.Text) > 0)
            {
                customeSrv.ChangePassword(Convert.ToInt32(Session["userID"]), txtPwd1.Text);
                Response.Write("<script>alert('密码修改成功')</script>");
               
            }
            else  //输入的原密码不正确
            {
                Response.Write("<script>alert('原密码不正确')</script>");
            }
        }
    }

    protected void Unnamed2_Click(object sender, EventArgs e)
    {
        Response.Redirect("../admin/Ask.aspx");
    }
}